package iconSwingStates.Transitions;

import iconSwingStates.Event.EVirtualIConEvent;

/**
 * A transition without tag
 * @author uribe - gaget
 *
 */
public class TTransition extends TGeneric{
        private String name;
        private String pointer=""; 
   
        /**
         * Constructor with a slot
         * @param nomTransition The name of the transition
         * @param pointer The name of the pointer
         * @param type The type of the slot
         * @param obligatory True if the slot must be connected
         * @param outputState The output state
         */
        public TTransition(String nomTransition,String pointer,int type, boolean obligatory,String outputState) {
            super(nomTransition,type,obligatory,false,outputState);
            name = nomTransition ;
            this.pointer=pointer;
        }
        /**
         * Constructor with more than one slot
         * @param nomTransition The name of the transition
         * @param pointer The name of the pointer
         * @param type The types of the slots
         * @param obligatory True if the slot must be connected
         * @param synchro True if the slots must have a synchronized activity
         * @param outputState The output state
         */
        public TTransition(String nomTransition,String pointer,int[] type, boolean obligatory,boolean synchro,String outputState) {
            super(nomTransition, type,obligatory,synchro,outputState);
            name = nomTransition;
            this.pointer=pointer;
        }
        
        /**
         * Constructor with a slot
         * @param nomTransition The name of the transition
         * @param pointer The name of the pointer
         * @param type The type of the slot
         * @param obligatory True if the slot must be connected
         */
        public TTransition(String nomTransition, String pointer, int type,boolean obligatory) {
            super(nomTransition,type,obligatory,false);
            name = nomTransition;
            this.pointer=pointer;
        }
        /**
         * Constructor with more than one slot
         * @param nomTransition The name of the transition
         * @param pointer The name of the pointer
         * @param type The types of the slots
         * @param obligatory True if the slot must be connected
         * @param synchro True if the slots must have a synchronized activity
         */
        public TTransition(String nomTransition,int[] type, boolean obligatory,boolean synchro) {
            super(nomTransition,type,obligatory,synchro);
            name = nomTransition;
        }
   
        public TTransition(String nomTransition, String pointer,int[] type,boolean obligatory,boolean synchro) {
            super(nomTransition,type,obligatory,false);
            name = nomTransition ;
            this.pointer=pointer;
        }
          
		/**
		 * Constructor without pointer and with a slot
		 * @param nomTransition Name of the transition
		 * @param type Type of the slot
		 * @param obligatory True if the slot must be connected
		 */
		public TTransition(String nomTransition, int type, boolean obligatory) {
			super(nomTransition,type,obligatory);
			name = nomTransition;
		}
		/**
		 * Constructor without pointer and with a slot
		 * @param nomTransition Name of the transition
		 * @param type Type of the slot
		 * @param obligatory True if the slot must be connected
		 * @param outputState The output state
		 */
		public TTransition(String nomTransition, int type, boolean obligatory, String outputState) {
			super(nomTransition,type,obligatory,outputState);
			name = nomTransition;
		}

		/**
         * Cf method matches from VirtualEvent
         * @param eventObject
         * @return true if the same event
         */
        public boolean matches(EVirtualIConEvent eventObject) {
                if(classEvent != null) {
                        return classEvent.isAssignableFrom(EVirtualIConEvent.class);
                } else {
                        if (eventObject instanceof EVirtualIConEvent) {
                                String event = ((EVirtualIConEvent) eventObject).getNameEvent();
                                return (event == null);
                        }
                }
                return false;
        }
        public String getName(){
        	return name;
        }

    	public boolean equals(Object obj) {
    		if(obj instanceof TTransition){
    			TTransition tr = (TTransition)obj;
    			if(tr.getName().compareTo(name) == 0 && getInputState().getName().compareTo(tr.getInputState().getName()) == 0){
    				return true;
    			}
    			
    		}
    		return false;
    	}
        /**
         * Return the pointer
         * @return the pointer
         */
		public String getPointer(){
			return pointer;
		}
}